from sklearn.mixture import GaussianMixture
from sklearn.metrics import accuracy_score
import numpy as np
import pandas as pd
from python_ai.common.xcommon import sep
pd.set_option('display.max_columns', None)

dr = pd.read_csv(r'../../../../large_data/ML2/HeightWeight.csv')
x = dr.iloc[:, 1:]
y = dr.iloc[:, 0]

k = len(np.unique(y))
print(f'k = {k}')

model = GaussianMixture(n_components=k,
                        covariance_type='diag',  # ATTENTION diag and full, 哪个效果好，用哪个
                        # covariance_type='full',
                        random_state=33,
                        )
model.fit(x)
h = model.predict(x)
print(f'acc = {accuracy_score(y, h)}')
